package cn.kgc.vuehangbanhou.controller;

import cn.kgc.vuehangbanhou.pojo.Flight;
import cn.kgc.vuehangbanhou.pojo.ResultEntity;
import cn.kgc.vuehangbanhou.service.FlightService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
public class FlightController {
       @Resource
    FlightService flightService;
       @RequestMapping("/seleFlight")
    public ResultEntity<List<Flight>> seleFlight(@RequestParam(value = "qifei",required = false,defaultValue = "0")Integer qifei,
                                   @RequestParam(value = "daoda",required = false,defaultValue = "0")Integer daoda){
           List<Flight> sele = flightService.sele(qifei, daoda);
           return ResultEntity.successWithoutData(sele);
       }

       @RequestMapping("/addFlight")
       public ResultEntity<String> addFlight(@RequestBody Flight flight) {
           Integer add = flightService.add(flight);
           if (add > 0) {
               return ResultEntity.successWithoutData("SUCCESS");
           } else {
               return ResultEntity.successWithoutData("fail");
           }
       }
}
